package com.stk.doublebreak;

import org.andengine.entity.particle.SpriteParticleSystem;
import org.andengine.entity.particle.emitter.IParticleEmitter;
import org.andengine.entity.particle.initializer.BlendFunctionParticleInitializer;
import org.andengine.entity.particle.initializer.RotationParticleInitializer;
import org.andengine.entity.particle.initializer.VelocityParticleInitializer;
import org.andengine.entity.particle.modifier.AlphaParticleModifier;
import org.andengine.entity.particle.modifier.ColorParticleModifier;
import org.andengine.entity.particle.modifier.ExpireParticleModifier;
import org.andengine.entity.particle.modifier.IParticleModifier;
import org.andengine.entity.particle.modifier.ScaleParticleModifier;
import org.andengine.entity.sprite.Sprite;
import org.andengine.opengl.texture.region.ITextureRegion;
import org.andengine.opengl.vbo.VertexBufferObjectManager;

import android.opengl.GLES20;

public class Smoke extends SpriteParticleSystem {
	
	IParticleModifier<Sprite> colorModifier;

	public Smoke(IParticleEmitter pParticleEmitter, float pRateMinimum,	float pRateMaximum, int pParticlesMaximum, ITextureRegion pTextureRegion, VertexBufferObjectManager pVertexBufferObjectManager, int level, int width, int height) {
		super(pParticleEmitter, pRateMinimum, pRateMaximum, pParticlesMaximum, pTextureRegion, pVertexBufferObjectManager);
		
		this.addParticleInitializer(new BlendFunctionParticleInitializer<Sprite>(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE));
		this.addParticleInitializer(new VelocityParticleInitializer<Sprite>((100 + level*5) , (100 + level*5) + 20, ((100 + level*5) * height) / width, (((100 + level*5) * height) / width)+20));
		this.addParticleInitializer(new RotationParticleInitializer<Sprite>(0.0f, 360.0f));

		this.addParticleModifier(new ScaleParticleModifier<Sprite>(0f, 1.0f, 0.5f, 3.0f));
		this.addParticleModifier(new ExpireParticleModifier<Sprite>(1.0f));
		this.addParticleModifier(new AlphaParticleModifier<Sprite>(0.5f, 1.0f, 1.0f, 0.0f));
		
		colorModifier =  new ColorParticleModifier<Sprite>(0f, 0f,1f,1f,1f,1f,1f,1f); 
		this.addParticleModifier(colorModifier);
	}

	public IParticleModifier<Sprite> getColorModifier() {
		return colorModifier;
	}

	public void setColorModifier(IParticleModifier<Sprite> color) {
		this.removeParticleModifier(colorModifier);		
		this.addParticleModifier(color);
		this.colorModifier = color;
	}	
}
